package com.five.caipiao;
import java.util.Random;
public class caipiao {
    public static void main(String[] args) {

        int[] redBall = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
        int[] blueBall = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
        int[] end = new int[7];
        Random r = new Random();
        for (int i = 0; i < 6; i++) {
            int index = r.nextInt(33-i);
            end[i] = redBall[index];
            redBall = changeArray(redBall,index);
        }
        int index = r.nextInt(16);
        end[6] = blueBall[index];

        System.out.print("[");
        for (int i = 0; i < end.length; i++) {
            if(i==end.length-1){
                System.out.println(end[i] + "]");
            }else{
                System.out.print(end[i] + ", ");
            }
        }




    }

    //定义一个方法，取出数组中的一个元素并返回去掉该元素后的数组
    public static int[] changeArray(int[] arr,int index){
        int[] arr1 = new int[arr.length-1];
        for (int i = 0; i < arr.length; i++) {
            //arr[i]
            if(i<index){
                arr1[i] = arr[i];
            }else if(i>index){
                arr1[i-1] = arr[i];
            }

        }
        return arr1;
    }
}
